package vip.george.p0242;

import java.util.Arrays;

public class P242 {
    public boolean isAnagram(String s, String t) {
        if (s.length() != t.length()) {
            return false;
        }
        char[] sCharArray = s.toCharArray();
        Arrays.sort(sCharArray);
        String newS = new String(sCharArray);
        char[] tCharArray = t.toCharArray();
        Arrays.sort(tCharArray);
        String newT = new String(tCharArray);
        return newS.equals(newT);
    }

    public static void main(String[] args) {
        P242 p = new P242();
        System.out.println(p.isAnagram("anagram", "nagaram"));
        System.out.println(p.isAnagram("rat", "car"));
    }
}
